<%@page import="org.codehaus.jettison.json.JSONArray"%>
<%@page import="org.codehaus.jettison.json.JSONObject"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>Table Show</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="./html/css/style.css"></link>
	<script charset="utf-8" type="text/javascript" src="./html/js/jquery.js"></script>
	<script charset="utf-8" type="text/javascript" src="./html/js/table.js"></script>
  </head>
  
  <body>
	<h2>Schema <<%=request.getAttribute("schema") %>></h2>
	
	<table>
	 <% 
       String search = (String)request.getAttribute("searchM");
       %>
	    <a href="javascript:createTable('<%=path%>/createTableFile?type=<%=search%>')" class="yanshi">生成Java/vue文件</a>
	    &nbsp;&nbsp;&nbsp;
	    <a href="editerFreeMarkerServlet" class="yanshi" target="_bank">模板文件编辑</a><br>
	    <div style="margin-top: 20px">
		     <input type="checkbox" value="entity" id="checkEntity" name="checkCreate"/> 是否生成实体
<!-- 		     <input type="checkbox" value="dao" id="checkDao" name="checkCreate"/> 是否生成Dao -->
		     <input type="checkbox" value="service" id="checkService" name="checkCreate"/> 是否生成Service
		     <input type="checkbox" value="controller" id="checkAction" name="checkCreate"/> 是否生成Controller
		     <input type="checkbox" value="vo" id="checkVo" name="checkCreate"/> 是否生成VO
		     <input type="checkbox" value="js" id="checkJs" name="checkCreate"/> 是否生成JS
		      <input type="checkbox" value="vue" id="checkVUE" name="checkCreate"/> 是否生成VUE
<!-- 		     <input type="checkbox" value="biz" id="checkBiz" name="checkCreate"/> 是否生成Biz -->
	    </div>
	    <div style="margin-top: 20px">
		         生成java文件的路劲：<input type="text" name="pathC" id="shengcPath" value="F:/testTempleat"/>
	    </div>
	     <div style="margin-top: 20px">
		         生成vue/js文件的路劲：<input type="text" name="pathC1" id="shengcPath1" value="F:/testTempleat"/>
	    </div>
	    <div style="margin-top: 20px">
		     <a href="javascript:selectAllForTables()" class="yanshi">全选</a>
		     <a href="javascript:selectReverse()" class="yanshi">反选</a>
	    </div>
	    <form method="post" id="formId" action="gettable">
		    <div style="margin-top: 20px">
		         <input type="radio" value="pers" id="pers" name="search" <%if(search != "" && search.equals("pers")){ %> checked="checked" <%} %>/> pers
			     <input type="radio" value="pat" id="pat" name="search" <%if(search != "" && search.equals("pat")){ %> checked="checked" <%} %>/> pat
			      <input type="radio" value="ele" id="ele" name="search" <%if(search != "" && search.equals("pat")){ %> checked="checked" <%} %>/> ele
			     <input type="radio" value="acc" id="acc" name="search" <%if(search != "" && search.equals("acc")){ %> checked="checked" <%} %>/> acc
			     <input type="radio" value="vis" id="vis" name="search" <%if(search != "" && search.equals("vis")){ %> checked="checked" <%} %>/> vis
			     </br>
			     
		    </div>
		    <div style="margin-top: 20px">
		     <a href="javascript:submit('formId')" class="yanshi">查询</a>
	       </div>
	    </form>
	</table>
	<table class="bordered">
		<thead>
			<tr>
				<th><input type="checkbox" onchange="selectAll(this.checked)" id="checkAll" name="checkAll"/></th>
				<th>table</th>
				<th>columnName</th>
				<th>javaType</th>
				<th>dbType</th>
				<th>columnLen</th>
			</tr>
		</thead>
		<%
	    Map<String, String> map = (Map<String, String>)request.getAttribute("tableAll");
	    Set<String> keys = map.keySet();
	    JSONObject jsonObject = null;
	    JSONObject tableObj = null;
	    JSONArray columnObJsonArray = null;
	    for (String key : keys)
	    {
	        tableObj = new JSONObject(map.get(key));
	        columnObJsonArray = tableObj.getJSONArray(key);
	        for (int i = 0; i < columnObJsonArray.length(); i++)
	        {
	            jsonObject = columnObJsonArray.getJSONObject(i);
        %> 
                <tr>
                     <%  
                     if(i == 0)
                     {
	                  %>
	                    <td><input type="checkbox" name="tableName" value="<%=key%>"/></td>
					    <td><%=key%></td>
	                  <%
                     }
                     else
                     {
                      %>
                        <td></td>
					    <td></td>
                      <%
                     } 
                     %>
					<td><%=jsonObject.getString("columnName").toLowerCase()%> </td>
					<td><%=jsonObject.get("javaType")%></td>
					<td><%=jsonObject.get("dbType")%></td>
					<td><%=jsonObject.get("columnLen")%> </td>
				</tr>
                
                
    <%	            
	        }
	    }
	%>
	</table>
	<br>
	<br>
</body>
</html>
